from datetime import datetime
from typing import Optional
from pydantic import BaseModel, Field

from app.utils.tool import to_lower_camel


class OrderInSchema(BaseModel):
    coupon_id: int = Field(alias="couponId")


class OrderDetailInSchema(BaseModel):
    order_id: int


class OrderListInSchema(BaseModel):
    page: int = 1
    page_size: int = 10
    status: int


class OrderAppListInSchema(BaseModel):
    page: int = 1
    size: int = 10


class OrderAppCancleInSchema(BaseModel):
    qr_code: str = Field(..., description="订单二维码", alias="qrCode")


class OrderOutSchema(BaseModel):
    id: int
    coupon_id: Optional[int] = None
    coupon_name: str | None
    coupon_cate_id: int | None
    coupon_cate_name: str | None
    discount_amount: Optional[float] = None
    min_amount: Optional[float] = None
    start_time: datetime | None
    end_time: datetime | None
    created_time: datetime | None
    cancel_time: datetime | None
    status: int | None
    description: str | None
    qr_code: str
    model_config = {
        "alias_generator": to_lower_camel,
        "populate_by_name": True,
    }


class OrderAppOutSchema(BaseModel):
    id: int
    coupon_id: Optional[int] = None
    coupon_name: str | None
    coupon_cate_id: int | None
    coupon_cate_name: str | None
    discount_amount: Optional[float] = None
    min_amount: Optional[float] = None
    start_time: datetime | None
    end_time: datetime | None
    created_time: datetime | None
    cancel_time: datetime | None
    status: int | None
    model_config = {
        "alias_generator": to_lower_camel,
        "populate_by_name": True,
    }
